package unb.wikinarua.geopartitura.service.xmpp;

import unb.wikinarua.geopartitura.util.Constants;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;

public class XMPPServiceStarter extends BroadcastReceiver {
	
	@Override
    public void onReceive(Context context, Intent intent) {
        Log.d(Constants.TAG, "XMPPServiceStarter . BOOT COMPLETED");
        
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        if (prefs.getBoolean("prefAutoStartKey", true)) {
        	Log.d(Constants.TAG, "XMPPServiceStarter . Trying to connect");

        	Intent serviceIntent = new Intent();
        	serviceIntent.setAction(XMPPConnectionService.class.toString());
        	context.startService(serviceIntent);
        }
    }

}
